#include <stdio.h>

unsigned int _abs(unsigned int x1, unsigned int x2) {
	if(x1 > x2)
		return (x1 - x2) - 1;
	return (x2 - x1) - 1;
}

int main() {
	unsigned int T, Ai, Pi, Bj, Pj, diff;
	scanf("%d", &T);
	while(T--) {
		scanf("%d %d %d %d", &Ai, &Pi, &Bj, &Pj);
		diff = _abs(Pi, Pj);
		
		if(	((Ai > Bj) && ((diff % 3 == 1) || (diff % 3 == 2))) ||
			((Ai < Bj) && (diff % 3 == 0)) )
			printf("1\n");
		else
			printf("0\n");			
	}
	return 0;
}


